.class public Lcom/netease/newsreader/weibo/OAuthHelper;
.super Ljava/lang/Object;
.source "OAuthHelper.java"


# static fields
.field public static final HTTP_STAT:Ljava/lang/String; = "stat"


# direct methods
.method public constructor <init>()V
    .locals 0

    .prologue
    .line 37
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method public static generateQueryString(Ljava/lang/String;Ljava/util/Map;)Ljava/lang/String;
    .locals 5
    .parameter "url"
    .parameter
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/lang/String;",
            "Ljava/util/Map",
            "<",
            "Ljava/lang/String;",
            "Ljava/lang/String;",
            ">;)",
            "Ljava/lang/String;"
        }
    .end annotation

    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 196
    .local p1, p:Ljava/util/Map;,"Ljava/util/Map<Ljava/lang/String;Ljava/lang/String;>;"
    invoke-interface {p1}, Ljava/util/Map;->entrySet()Ljava/util/Set;

    move-result-object v1

    invoke-interface {v1}, Ljava/util/Set;->iterator()Ljava/util/Iterator;

    move-result-object v2

    :goto_0
    invoke-interface {v2}, Ljava/util/Iterator;->hasNext()Z

    move-result v1

    if-nez v1, :cond_0

    .line 200
    return-object p0

    .line 196
    :cond_0
    invoke-interface {v2}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/util/Map$Entry;

    .line 197
    .local v0, entry:Ljava/util/Map$Entry;,"Ljava/util/Map$Entry<Ljava/lang/String;Ljava/lang/String;>;"
    const/4 v1, 0x2

    new-array v3, v1, [Ljava/lang/String;

    const/4 v4, 0x0

    invoke-interface {v0}, Ljava/util/Map$Entry;->getKey()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Ljava/lang/String;

    aput-object v1, v3, v4

    const/4 v4, 0x1

    .line 198
    invoke-interface {v0}, Ljava/util/Map$Entry;->getValue()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Ljava/lang/String;

    aput-object v1, v3, v4

    .line 197
    invoke-static {p0, v3}, Lnet/oauth/OAuth;->addParameters(Ljava/lang/String;[Ljava/lang/String;)Ljava/lang/String;

    move-result-object p0

    goto :goto_0
.end method

.method public static perpareHeader(Lnet/oauth/OAuthAccessor;Ljava/lang/String;Ljava/util/Map;Ljava/lang/String;)[Lorg/apache/http/Header;
    .locals 11
    .parameter "accessor"
    .parameter "type"
    .parameter
    .parameter "url"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Lnet/oauth/OAuthAccessor;",
            "Ljava/lang/String;",
            "Ljava/util/Map",
            "<",
            "Ljava/lang/String;",
            "Ljava/lang/String;",
            ">;",
            "Ljava/lang/String;",
            ")[",
            "Lorg/apache/http/Header;"
        }
    .end annotation

    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lnet/oauth/OAuthException;,
            Ljava/io/IOException;,
            Ljava/net/URISyntaxException;
        }
    .end annotation

    .prologue
    .line 113
    .local p2, props:Ljava/util/Map;,"Ljava/util/Map<Ljava/lang/String;Ljava/lang/String;>;"
    new-instance v4, Ljava/util/ArrayList;

    invoke-direct {v4}, Ljava/util/ArrayList;-><init>()V

    .line 114
    .local v4, list:Ljava/util/List;,"Ljava/util/List<Lnet/oauth/OAuth$Parameter;>;"
    if-eqz p2, :cond_0

    .line 115
    invoke-interface {p2}, Ljava/util/Map;->entrySet()Ljava/util/Set;

    move-result-object v7

    invoke-interface {v7}, Ljava/util/Set;->iterator()Ljava/util/Iterator;

    move-result-object v9

    :goto_0
    invoke-interface {v9}, Ljava/util/Iterator;->hasNext()Z

    move-result v7

    if-nez v7, :cond_1

    .line 120
    :cond_0
    new-instance v6, Lnet/oauth/OAuthMessage;

    invoke-direct {v6, p1, p3, v4}, Lnet/oauth/OAuthMessage;-><init>(Ljava/lang/String;Ljava/lang/String;Ljava/util/Collection;)V

    .line 121
    .local v6, request:Lnet/oauth/OAuthMessage;
    invoke-virtual {v6, p0}, Lnet/oauth/OAuthMessage;->addRequiredParameters(Lnet/oauth/OAuthAccessor;)V

    .line 123
    sget-object v7, Lnet/oauth/ParameterStyle;->AUTHORIZATION_HEADER:Lnet/oauth/ParameterStyle;

    .line 122
    invoke-static {v6, v7}, Lnet/oauth/http/HttpMessage;->newRequest(Lnet/oauth/OAuthMessage;Lnet/oauth/ParameterStyle;)Lnet/oauth/http/HttpMessage;

    move-result-object v3

    .line 125
    .local v3, httpRequest:Lnet/oauth/http/HttpMessage;
    new-instance v5, Ljava/util/ArrayList;

    invoke-direct {v5}, Ljava/util/ArrayList;-><init>()V

    .line 127
    .local v5, newHeaders:Ljava/util/List;,"Ljava/util/List<Lorg/apache/http/Header;>;"
    iget-object v7, v3, Lnet/oauth/http/HttpMessage;->headers:Ljava/util/List;

    invoke-interface {v7}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object v9

    :goto_1
    invoke-interface {v9}, Ljava/util/Iterator;->hasNext()Z

    move-result v7

    if-nez v7, :cond_2

    .line 130
    invoke-interface {v5}, Ljava/util/List;->size()I

    move-result v7

    new-array v2, v7, [Lorg/apache/http/Header;

    .line 131
    .local v2, headers:[Lorg/apache/http/Header;
    invoke-interface {v5, v2}, Ljava/util/List;->toArray([Ljava/lang/Object;)[Ljava/lang/Object;

    move-result-object v7

    check-cast v7, [Lorg/apache/http/Header;

    return-object v7

    .line 115
    .end local v2           #headers:[Lorg/apache/http/Header;
    .end local v3           #httpRequest:Lnet/oauth/http/HttpMessage;
    .end local v5           #newHeaders:Ljava/util/List;,"Ljava/util/List<Lorg/apache/http/Header;>;"
    .end local v6           #request:Lnet/oauth/OAuthMessage;
    :cond_1
    invoke-interface {v9}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/util/Map$Entry;

    .line 116
    .local v0, entry:Ljava/util/Map$Entry;,"Ljava/util/Map$Entry<Ljava/lang/String;Ljava/lang/String;>;"
    new-instance v10, Lnet/oauth/OAuth$Parameter;

    invoke-interface {v0}, Ljava/util/Map$Entry;->getKey()Ljava/lang/Object;

    move-result-object v7

    check-cast v7, Ljava/lang/String;

    .line 117
    invoke-interface {v0}, Ljava/util/Map$Entry;->getValue()Ljava/lang/Object;

    move-result-object v8

    check-cast v8, Ljava/lang/String;

    invoke-direct {v10, v7, v8}, Lnet/oauth/OAuth$Parameter;-><init>(Ljava/lang/String;Ljava/lang/String;)V

    .line 116
    invoke-interface {v4, v10}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    goto :goto_0

    .line 127
    .end local v0           #entry:Ljava/util/Map$Entry;,"Ljava/util/Map$Entry<Ljava/lang/String;Ljava/lang/String;>;"
    .restart local v3       #httpRequest:Lnet/oauth/http/HttpMessage;
    .restart local v5       #newHeaders:Ljava/util/List;,"Ljava/util/List<Lorg/apache/http/Header;>;"
    .restart local v6       #request:Lnet/oauth/OAuthMessage;
    :cond_2
    invoke-interface {v9}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Ljava/util/Map$Entry;

    .line 128
    .local v1, header:Ljava/util/Map$Entry;,"Ljava/util/Map$Entry<Ljava/lang/String;Ljava/lang/String;>;"
    new-instance v10, Lorg/apache/http/message/BasicHeader;

    invoke-interface {v1}, Ljava/util/Map$Entry;->getKey()Ljava/lang/Object;

    move-result-object v7

    check-cast v7, Ljava/lang/String;

    invoke-interface {v1}, Ljava/util/Map$Entry;->getValue()Ljava/lang/Object;

    move-result-object v8

    check-cast v8, Ljava/lang/String;

    invoke-direct {v10, v7, v8}, Lorg/apache/http/message/BasicHeader;-><init>(Ljava/lang/String;Ljava/lang/String;)V

    invoke-interface {v5, v10}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    goto :goto_1
.end method

.method public static perpareQueryString(Lnet/oauth/OAuthAccessor;Ljava/lang/String;Ljava/util/Properties;Ljava/lang/String;)Ljava/net/URL;
    .locals 8
    .parameter "accessor"
    .parameter "type"
    .parameter "props"
    .parameter "url"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lnet/oauth/OAuthException;,
            Ljava/io/IOException;,
            Ljava/net/URISyntaxException;
        }
    .end annotation

    .prologue
    .line 148
    new-instance v2, Ljava/util/ArrayList;

    invoke-direct {v2}, Ljava/util/ArrayList;-><init>()V

    .line 149
    .local v2, list:Ljava/util/List;,"Ljava/util/List<Lnet/oauth/OAuth$Parameter;>;"
    invoke-virtual {p2}, Ljava/util/Properties;->entrySet()Ljava/util/Set;

    move-result-object v4

    invoke-interface {v4}, Ljava/util/Set;->iterator()Ljava/util/Iterator;

    move-result-object v6

    :goto_0
    invoke-interface {v6}, Ljava/util/Iterator;->hasNext()Z

    move-result v4

    if-nez v4, :cond_0

    .line 153
    new-instance v3, Lnet/oauth/OAuthMessage;

    invoke-direct {v3, p1, p3, v2}, Lnet/oauth/OAuthMessage;-><init>(Ljava/lang/String;Ljava/lang/String;Ljava/util/Collection;)V

    .line 154
    .local v3, request:Lnet/oauth/OAuthMessage;
    invoke-virtual {v3, p0}, Lnet/oauth/OAuthMessage;->addRequiredParameters(Lnet/oauth/OAuthAccessor;)V

    .line 156
    sget-object v4, Lnet/oauth/ParameterStyle;->QUERY_STRING:Lnet/oauth/ParameterStyle;

    .line 155
    invoke-static {v3, v4}, Lnet/oauth/http/HttpMessage;->newRequest(Lnet/oauth/OAuthMessage;Lnet/oauth/ParameterStyle;)Lnet/oauth/http/HttpMessage;

    move-result-object v1

    .line 158
    .local v1, httpRequest:Lnet/oauth/http/HttpMessage;
    iget-object v4, v1, Lnet/oauth/http/HttpMessage;->url:Ljava/net/URL;

    return-object v4

    .line 149
    .end local v1           #httpRequest:Lnet/oauth/http/HttpMessage;
    .end local v3           #request:Lnet/oauth/OAuthMessage;
    :cond_0
    invoke-interface {v6}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/util/Map$Entry;

    .line 150
    .local v0, entry:Ljava/util/Map$Entry;,"Ljava/util/Map$Entry<Ljava/lang/Object;Ljava/lang/Object;>;"
    new-instance v7, Lnet/oauth/OAuth$Parameter;

    invoke-interface {v0}, Ljava/util/Map$Entry;->getKey()Ljava/lang/Object;

    move-result-object v4

    check-cast v4, Ljava/lang/String;

    .line 151
    invoke-interface {v0}, Ljava/util/Map$Entry;->getValue()Ljava/lang/Object;

    move-result-object v5

    check-cast v5, Ljava/lang/String;

    invoke-direct {v7, v4, v5}, Lnet/oauth/OAuth$Parameter;-><init>(Ljava/lang/String;Ljava/lang/String;)V

    .line 150
    invoke-interface {v2, v7}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    goto :goto_0
.end method

.method public static processResponse(Ljava/lang/String;)Ljava/util/Map;
    .locals 10
    .parameter "response"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/lang/String;",
            ")",
            "Ljava/util/Map",
            "<",
            "Ljava/lang/String;",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation

    .prologue
    const/4 v7, 0x0

    .line 168
    new-instance v2, Ljava/util/HashMap;

    invoke-direct {v2}, Ljava/util/HashMap;-><init>()V

    .line 169
    .local v2, p:Ljava/util/Map;,"Ljava/util/Map<Ljava/lang/String;Ljava/lang/String;>;"
    const-string v5, "&"

    invoke-virtual {p0, v5}, Ljava/lang/String;->split(Ljava/lang/String;)[Ljava/lang/String;

    move-result-object v4

    .line 171
    .local v4, params:[Ljava/lang/String;
    array-length v8, v4

    move v6, v7

    :goto_0
    if-lt v6, v8, :cond_0

    .line 184
    return-object v2

    .line 171
    :cond_0
    aget-object v3, v4, v6

    .line 172
    .local v3, param:Ljava/lang/String;
    const-string v5, "="

    invoke-virtual {v3, v5}, Ljava/lang/String;->split(Ljava/lang/String;)[Ljava/lang/String;

    move-result-object v1

    .line 173
    .local v1, name2value:[Ljava/lang/String;
    array-length v5, v1

    const/4 v9, 0x2

    if-eq v5, v9, :cond_2

    .line 174
    const-string v0, ""

    .line 175
    .local v0, key:Ljava/lang/String;
    invoke-interface {v2, v0}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v5

    if-nez v5, :cond_1

    .line 176
    invoke-interface {v2, v0, v3}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 171
    .end local v0           #key:Ljava/lang/String;
    :goto_1
    add-int/lit8 v5, v6, 0x1

    move v6, v5

    goto :goto_0

    .line 178
    .restart local v0       #key:Ljava/lang/String;
    :cond_1
    invoke-interface {v2, v0}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v5

    check-cast v5, Ljava/lang/String;

    const-string v9, "||"

    invoke-virtual {v5, v9}, Ljava/lang/String;->concat(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v5

    invoke-virtual {v5, v3}, Ljava/lang/String;->concat(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v5

    invoke-interface {v2, v0, v5}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    goto :goto_1

    .line 181
    .end local v0           #key:Ljava/lang/String;
    :cond_2
    aget-object v5, v1, v7

    const/4 v9, 0x1

    aget-object v9, v1, v9

    invoke-interface {v2, v5, v9}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    goto :goto_1
.end method

.method public static requestGet(Lorg/apache/http/client/HttpClient;Ljava/lang/String;)Lorg/apache/http/HttpResponse;
    .locals 1
    .parameter "client"
    .parameter "urlWithParam"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 49
    const/4 v0, 0x0

    invoke-static {p0, p1, v0}, Lcom/netease/newsreader/weibo/OAuthHelper;->requestGet(Lorg/apache/http/client/HttpClient;Ljava/lang/String;[Lorg/apache/http/Header;)Lorg/apache/http/HttpResponse;

    move-result-object v0

    return-object v0
.end method

.method public static requestGet(Lorg/apache/http/client/HttpClient;Ljava/lang/String;[Lorg/apache/http/Header;)Lorg/apache/http/HttpResponse;
    .locals 6
    .parameter "client"
    .parameter "urlWithParam"
    .parameter "headers"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    const/4 v4, 0x0

    .line 62
    const/4 v1, 0x0

    .line 64
    .local v1, httpget:Lorg/apache/http/client/methods/HttpGet;
    new-instance v1, Lorg/apache/http/client/methods/HttpGet;

    .end local v1           #httpget:Lorg/apache/http/client/methods/HttpGet;
    invoke-direct {v1, p1}, Lorg/apache/http/client/methods/HttpGet;-><init>(Ljava/lang/String;)V

    .line 65
    .restart local v1       #httpget:Lorg/apache/http/client/methods/HttpGet;
    new-instance v2, Lorg/apache/http/params/BasicHttpParams;

    invoke-direct {v2}, Lorg/apache/http/params/BasicHttpParams;-><init>()V

    .line 66
    .local v2, params:Lorg/apache/http/params/HttpParams;
    invoke-static {v2, v4}, Lorg/apache/http/client/params/HttpClientParams;->setRedirecting(Lorg/apache/http/params/HttpParams;Z)V

    .line 67
    invoke-virtual {v1, v2}, Lorg/apache/http/client/methods/HttpGet;->setParams(Lorg/apache/http/params/HttpParams;)V

    .line 68
    if-eqz p2, :cond_0

    .line 69
    array-length v5, p2

    :goto_0
    if-lt v4, v5, :cond_1

    .line 73
    :cond_0
    const-string v4, "Content-Type"

    const-string v5, "application/atom+xml"

    invoke-virtual {v1, v4, v5}, Lorg/apache/http/client/methods/HttpGet;->addHeader(Ljava/lang/String;Ljava/lang/String;)V

    .line 74
    invoke-interface {p0, v1}, Lorg/apache/http/client/HttpClient;->execute(Lorg/apache/http/client/methods/HttpUriRequest;)Lorg/apache/http/HttpResponse;

    move-result-object v3

    .line 76
    .local v3, response:Lorg/apache/http/HttpResponse;
    return-object v3

    .line 69
    .end local v3           #response:Lorg/apache/http/HttpResponse;
    :cond_1
    aget-object v0, p2, v4

    .line 70
    .local v0, header:Lorg/apache/http/Header;
    invoke-virtual {v1, v0}, Lorg/apache/http/client/methods/HttpGet;->addHeader(Lorg/apache/http/Header;)V

    .line 69
    add-int/lit8 v4, v4, 0x1

    goto :goto_0
.end method

.method public static requestPostMultiPart(Lorg/apache/http/client/HttpClient;Ljava/lang/String;Lnet/oauth/OAuthAccessor;Ljava/util/Properties;Ljava/util/Properties;)Lorg/apache/http/HttpResponse;
    .locals 3
    .parameter "client"
    .parameter "urlWithParam"
    .parameter "accessor"
    .parameter "oauthProps"
    .parameter "postInfo"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/Exception;
        }
    .end annotation

    .prologue
    .line 92
    new-instance v0, Lcom/netease/newsreader/weibo/PostEntityMultiPart;

    invoke-direct {v0, p2, p3}, Lcom/netease/newsreader/weibo/PostEntityMultiPart;-><init>(Lnet/oauth/OAuthAccessor;Ljava/util/Properties;)V

    .line 93
    .local v0, entity:Lcom/netease/newsreader/weibo/PostEntity;
    invoke-virtual {v0, p1, p4}, Lcom/netease/newsreader/weibo/PostEntity;->getHttpPost(Ljava/lang/String;Ljava/util/Properties;)Lorg/apache/http/client/methods/HttpPost;

    move-result-object v1

    .line 94
    .local v1, httppost:Lorg/apache/http/client/methods/HttpPost;
    invoke-interface {p0, v1}, Lorg/apache/http/client/HttpClient;->execute(Lorg/apache/http/client/methods/HttpUriRequest;)Lorg/apache/http/HttpResponse;

    move-result-object v2

    .line 96
    .local v2, response:Lorg/apache/http/HttpResponse;
    return-object v2
.end method

.method public static requestPostUrlEncode(Lorg/apache/http/client/HttpClient;Ljava/lang/String;Lnet/oauth/OAuthAccessor;Ljava/util/Properties;Ljava/util/Properties;)Lorg/apache/http/HttpResponse;
    .locals 3
    .parameter "client"
    .parameter "urlWithParam"
    .parameter "accessor"
    .parameter "oauthProps"
    .parameter "postInfo"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/Exception;
        }
    .end annotation

    .prologue
    .line 82
    new-instance v0, Lcom/netease/newsreader/weibo/PostEntityUrlEncode;

    invoke-direct {v0, p2, p3}, Lcom/netease/newsreader/weibo/PostEntityUrlEncode;-><init>(Lnet/oauth/OAuthAccessor;Ljava/util/Properties;)V

    .line 83
    .local v0, entity:Lcom/netease/newsreader/weibo/PostEntity;
    invoke-virtual {v0, p1, p4}, Lcom/netease/newsreader/weibo/PostEntity;->getHttpPost(Ljava/lang/String;Ljava/util/Properties;)Lorg/apache/http/client/methods/HttpPost;

    move-result-object v1

    .line 84
    .local v1, httppost:Lorg/apache/http/client/methods/HttpPost;
    invoke-interface {p0, v1}, Lorg/apache/http/client/HttpClient;->execute(Lorg/apache/http/client/methods/HttpUriRequest;)Lorg/apache/http/HttpResponse;

    move-result-object v2

    .line 86
    .local v2, response:Lorg/apache/http/HttpResponse;
    return-object v2
.end method
